package app.sceledroid.adapter;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import app.sceledroid.R;
import app.sceledroid.entity.Forum;
import app.sceledroid.entity.Resource;

public class ResourceAdapter extends ArrayAdapter<Resource> {

	private ArrayList<Resource> resources;
	
	public ResourceAdapter(Context context, int textViewResourceId,
			ArrayList<Resource> objects) {
		super(context, textViewResourceId, objects);
		this.resources = objects;
		// TODO Auto-generated constructor stub
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		View v = convertView;
		if (v == null) {
			Context context = super.getContext();
			LayoutInflater vi = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			v = vi.inflate(R.layout.course_resource_item, null);
		}
		Resource r = resources.get(position);
		
		TextView resourceName = (TextView)v.findViewById(R.id.resourceItemName);
		resourceName.setText(r.getName());
		
		
		return v;
	}

}
